package com.sevlet;

import com.Bean.Room;
import com.Bean.VoBean.OrderVo;
import com.dao.OrderDao;
import com.dao.RoomDao;
import com.dao.impl.OrderDaoimpl;
import com.dao.impl.RoomDaoimpl;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.util.JsonUtil;
import com.util.PageUtil;
import com.util.ProxyUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/RoomServlet.do")
public class RoomServlet extends BaseSevlet {
    public void queryRtid(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(222);
        RoomDao roomDao=(RoomDao) ProxyUtil.getDaoProxy(new RoomDaoimpl());
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out = resp.getWriter();
        JsonUtil jsonUtil =new JsonUtil();

        try {
            List<Room> rooms = roomDao.queryData(null);
            jsonUtil.setMsg("ok");
            jsonUtil.setData(rooms);
        } catch (Exception e) {
            e.printStackTrace();
            jsonUtil.setCode(1);
            jsonUtil.setMsg("系统错误");
        }
        GsonBuilder gsonBuilder = new GsonBuilder();
        Gson gson = gsonBuilder.create();
        String jsonstr = gson.toJson(jsonUtil);
        out.write(jsonstr);

    }



}
 
 
 

